"""
Assessment Plan 相关的请求和响应模型
"""
from datetime import datetime
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, Field

class AssessmentPlanBase(BaseModel):
    """
    Assessment Plan 基本模型，包含共用属性
    """
    name: str = Field(..., description="业务系统名称")
    rating_filing_name: str = Field(..., description="评级备案名称")
    responsible_person: str = Field(..., description="负责人")
    business_department: str = Field(..., description="业务部门")
    contact: str = Field(..., description="联系方式")
    assessment_type: str = Field(..., description="评估类型", pattern="^(101|102|103|104|105)$")    
    expected_completion_date: datetime = Field(..., description="预期完成日期")

class AssessmentPlanCreate(AssessmentPlanBase):
    """
    创建 Assessment Plan 的请求模型
    """
    template_id: UUID = Field(..., description="模板ID")

class AssessmentPlanUpdate(BaseModel):
    """
    更新 Assessment Plan 的请求模型，所有字段都是可选的
    """
    name: Optional[str] = Field(None, description="业务系统名称")
    rating_filing_name: Optional[str] = Field(None, description="评级备案名称")
    responsible_person: Optional[str] = Field(None, description="负责人")
    business_department: Optional[str] = Field(None, description="业务部门")
    contact: Optional[str] = Field(None, description="联系方式")
    assessment_type: Optional[str] = Field(None, description="评估类型", pattern="^(101|102|103|104|105)$")
    expected_completion_date: Optional[datetime] = Field(None, description="预期完成日期")
    status: Optional[str] = Field(None, description="系统状态", pattern="^(in_progress|completed)$")

class AssessmentPlanResponse(AssessmentPlanBase):
    """
    Assessment Plan 响应模型，包含所有字段
    """
    id: UUID = Field(..., description="唯一标识符")
    created_at: datetime = Field(..., description="创建时间")
    status: str = Field(..., description="系统状态")

    class Config:
        """Pydantic配置类"""
        from_attributes = True

class AssessmentPlanPagination(BaseModel):
    """
    分页查询响应模型
    """
    total: int = Field(..., description="总记录数")
    items: list[AssessmentPlanResponse] = Field(..., description="当前页数据")
